package com.example.controller.service;

import com.alibaba.fastjson.JSON;
import com.example.model.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import org.apache.rocketmq.spring.annotation.MessageModel;


//发送短信的服务
@Slf4j
@Service
@Component
//@RocketMQMessageListener(consumerGroup = "boot-user", topic = "order-topic")
//  selectorExpression = "${rocketmq.producer.tags}",
//,    messageModel = MessageModel.BROADCASTING

//boot-order
@RocketMQMessageListener(consumerGroup = "${rocketmq.producer.group}",
        topic = "${rocketmq.producer.topic}",
        selectorExpression = "${rocketmq.producer.tags}")
//@RocketMQMessageListener(consumerGroup = "boot-user", topic = "order-topic")
public class SmsService implements RocketMQListener<Order> {
    @Override
    public void onMessage(Order order) {
        log.info("收到一个订单信息{},接下来发送短信", JSON.toJSONString(order));
    }
}
